{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8a142faa",
   "metadata": {},
   "source": [
    "# 第一题\n",
    "+ **要求**：创建一个从0到9的一维数组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "60befa4d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 2, 3, 4])"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "arr1=np.array([0,1,2,3,4])\n",
    "arr1"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7f62e888",
   "metadata": {},
   "source": [
    "# 第二题\n",
    "+ **要求**：将arr中的奇数都修改成1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4488962a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "结果 [0 1 2 1 4 1 6 1 8 1]\n"
     ]
    }
   ],
   "source": [
    "arr= np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])\n",
    "arr[arr%2==1]=1\n",
    "print('结果',arr)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "89a2c010",
   "metadata": {},
   "source": [
    "# 第三题\n",
    "+ **要求**：将下面两个数组按照行进行合并,然后按列均等拆分成三个数组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "64d2de58",
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "operands could not be broadcast together with shapes (2,3) (3,3) ",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-11-28441249e1cf>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[0marr1\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0marray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[0marr2\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrandom\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrandint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m10\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[0marr1\u001b[0m\u001b[1;33m+\u001b[0m\u001b[0marr2\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m: operands could not be broadcast together with shapes (2,3) (3,3) "
     ]
    }
   ],
   "source": [
    "arr1=np.array([[1,2,3],[1,2,3]])\n",
    "arr2=np.random.randint(0,10,(3,3))\n",
    "arr1+arr2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7a8a62ab",
   "metadata": {},
   "source": [
    "# 第四题\n",
    "+ **要求**：创建一个10x10的随机浮点数矩阵，并找到最大值和最小值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "30a04fb6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<built-in method max of numpy.ndarray object at 0x00000246197739F0> <built-in method min of numpy.ndarray object at 0x00000246197739F0>\n"
     ]
    }
   ],
   "source": [
    "Z=np.random.random((10,10))\n",
    "Zmax,Zmin=Z.max(),Z.min()\n",
    "print(Z.max,Z.min)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6b8c874b",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
